package com.example.myapplication.list

import com.example.myapplication.TestResult
import com.example.myapplication.data.TestRespo
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import org.hades.corelib.base.di.IoDispatcher
import org.hades.corelib.base.exception.ApiException
import org.hades.corelib.base.usecase.FlowUseCase
import javax.inject.Inject

class TestListUseCase @Inject constructor(
    @IoDispatcher dispatcher: CoroutineDispatcher,
    private val repo: TestRespo
) : FlowUseCase<TestListUseCase.Params, List<TestResult>>(dispatcher) {
    override fun execute(parameters: Params): Flow<List<TestResult>> {
        return flow {
            // 通过respository获取网络数据
            emit(repo.getTestDatas(parameters.str))
        }
    }

    class Params : RequestValues{
        var str:String

        constructor(str: String) {
            this.str = str
        }
    }

}